<?php

class Digits
{
	public static function getImage($substance, $prefix)
	{
		return "/images/prices/digits/$prefix$substance.png";
	}
	
	public static function getPrice($price, $prefix, $unit = null)
	{
		if (!$price) {
			return null;
		}
		$digits = str_split(strval($price));
		foreach ($digits as $key => $digit) {
			$digits[$key] = self::getImage($digit, $prefix);
		}
		$item = array (
			'price_class' => $prefix . 'price',
			'digit_class' => $prefix . 'digit',
			'digits' => $digits,
			'unit' => ($unit) ? (self::getImage($unit, $prefix)) : (null),
			'price' => $price
		);
		return $item;
	}
}